1. Field of the Invention
The present invention relates to computers and computer software. More specifically, the invention is generally related to debugging software.
2. Background of the Related Art
Inherent in any software development technique is the potential for introducing xe2x80x9cbugsxe2x80x9d. A bug will typically cause unexpected results during the execution of the program. Locating, analyzing, and correcting bugs in a computer program is a process known as xe2x80x9cdebugging.xe2x80x9d Debugging of programs may be done either manually or interactively by a debugging system mediated by a computer system. Manual debugging of a program requires a programmer to manually trace the logic flow of the program and the contents of memory elements, e.g., registers and variables. In the interactive debugging of programs, the program is executed under the control of a monitor program (known as a xe2x80x9cdebuggerxe2x80x9d). The debugger is commonly located on and executed by the same computer system on which the program is executed.
Conventional debuggers typically support various operations to assist a computer programmer. Each operation allows the programmer to examine the state of program registers and variables at a given point in the execution of a program. A first operation supported by conventional debuggers is a breakpoint operation. A xe2x80x9cbreakpointxe2x80x9d is a point in the program where execution of the computer program is stopped so that the state of the program can be examined by a computer programmer. As a result, when a computer program is executed by a debugger, the program executes in a normal fashion until a breakpoint is reached. The debugger then stops execution and displays the results of the computer program to the programmer for analysis.
Most breakpoints supported by conventional debuggers are unconditional, meaning that once such a breakpoint is reached, execution of the program is always halted. Some debuggers also support the use of conditional breakpoints, which only halt execution of a program when a variable used by the program is set to a predetermined value at the time such a breakpoint is reached.
A second operation supported by conventional debuggers is a xe2x80x9cstepxe2x80x9d function. Step functions known in the art include xe2x80x9cstep throughxe2x80x9d (also known as xe2x80x9cstep intoxe2x80x9d) and xe2x80x9cstep overxe2x80x9d (also known as xe2x80x9cskipxe2x80x9d and xe2x80x9cnextxe2x80x9d) operations. Step functions permit a computer programmer to process instructions in a computer program at a source file level (i.e., line by line) and at a statement level, and see the results upon completion of each instruction.
Another operation commonly used by programmers debugging code is known as a xe2x80x9crun toxe2x80x9d operation. xe2x80x9cRun toxe2x80x9d operations allow a user to execute code until reaching a predetermined point. For example, a first xe2x80x9cRun toxe2x80x9d operation makes it possible to skip directly to the end of a procedure from a current position in the procedure. A second xe2x80x9crun toxe2x80x9d operation allows a programmer to determine where execution will be halted according to placement of a cursor.
Typically, step operations, breakpoints and xe2x80x9crun toxe2x80x9d operations are used together to simplify the debugging process. Specifically, a common debugging operation is to set a breakpoint at the beginning of a desired set of instructions to be analyzed, and then execute the program. Once the breakpoint is reached, the program is halted, and the programmer then steps through the desired set of instructions line by line or statement by statement using the step operation. Alternatively, the programmer may advance to subsequent points in code space using xe2x80x9crun toxe2x80x9d operations. Consequently, a programmer is able to isolate and analyze a particular set of instructions without having to step through irrelevant portions of a computer program.
Despite the advantages provided by conventional debugging operations, today""s programmers often find the need for additional flexibility. For example, it is often desirable to apply step operations to discrete blocks of code. Conventional solutions include using xe2x80x9crun toxe2x80x9d points and breakpoints in conjunction with step operations in the manner described above. However, these methods becomes exceedingly time-consuming when many separate blocks of code must be stepped through repeatedly. This also approach suffers because breakpoints are active even when the programmer is not interested in stepping, thereby impacting the efficiency of the programmer.
Another solution is to designate a number (N) of statements to step through. This method, offered by many conventional debuggers, is also burdensome to the programmer because the value of N must be calculated for each separate block of code, and N may be different for each time through the block depending on the control flow.
The disadvantages associated with the prior art are even more pronounced when the code being debugged is pre-processed by a code generator. A code generator operates to add code segments to the code being debugged which may be of no interest to a programmer, thereby further reducing the efficiency of the debugging process. Therefore, there is a need for a debugging program adapted to address the problems associated with step operations.
The present invention generally provides an apparatus, program product, and a method for debugging computer programs that facilitates step operations.
One aspect of the invention provides a method for debugging a target program containing code. The method comprises establishing a region of the code by designating an entry point in the code and an exit point in the code, executing the code, and halting execution of the code at a first executable instruction after the exit point.
Another aspect of the invention provides a signal bearing medium containing code for a program which, when executed by one or more processors, performs the method described above.
Another aspect of the invention provides a computer system comprising a processor, a memory, an input device, a display device and code for a program which, when executed by the processor, performs a method for debugging the code. The method comprises establishing a region of the code by designating an entry point in the code and an exit point in the code, executing the code, and halting execution of the code at a first executable instruction after the exit point.